#include "litelocker.h"

LiteLocker::LiteLocker(LiteMutex* mutex)
{
	if (!mutex)
		return;

	m_mutexPtr.store(static_cast<void*>(mutex), std::memory_order_release);
	mutex->lock();
}

LiteLocker::~LiteLocker()
{
	LiteMutex* temp = static_cast<LiteMutex*>(m_mutexPtr.load(std::memory_order_acquire));
	if (!temp)
		return;
	temp->unlock();
}